# -*- coding:utf-8 -*-
from configparser import ConfigParser
from untile .handle_path import conf_path
import os
class Handle_conf(ConfigParser):
    '''当前这个类是用来处理conf.ini文件的工具类'''
    def __init__(self,filename):
        super(Handle_conf, self).__init__()#继承父类的构造方法
        self.filename = filename
        self.read(filename,encoding="utf8")
        # self.read(filename,encoding="utf8")


    def get_value(self,section,option):
        '''获取ini文件中的section的option的value值'''
        value = self.get(section,option)
        return value

# path = os.path.join(conf_path,"conf.ini")
conf = Handle_conf(os.path.join(conf_path,"conf.ini"))
# print(conf.get_value('env',"url"))
# print(conf.get_value('env',"headers"))
# print(conf.get_value('test_data',"username"))
# print(conf.get_value('test_data',"password"))

# import os
# from configparser import ConfigParser
# from common.handlepath import CONFDIR
# class HandleConfig(ConfigParser):
#     def __init__(self, filename):#调用父类的init方法
#         super().__init__()
#         self.filename=filename
#
#         self.read(filename,encoding="utf8")
#
#     def write_data(self, section, options, value):"""写入数据的方法"""
#         self.set(section, options, value)
#
#         self.write(fp=open(self.filename, "w"))
#
#     conf= HandleConfig(os.path.join(CONFDIR,"config.ini"))
#     print(conf.get("log","level")) #拿到了log对应的字段DEBUG

